package com.pangu.export.utils;

import com.pangu.export.entity.TableColumn;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by etfox on 2019/10/25 22:54
 */
public class MapUtil {

    public static Map<String, List<TableColumn>> dealTableColumn(List<TableColumn> tableColumns) {

        Map<String, List<TableColumn>> map = new HashMap<>();
        for (TableColumn tableColumn : tableColumns) {
            // 查看map中是否存在该键
            if (map.keySet().contains(tableColumn.getTableName())) {// 存在
                List<TableColumn> columns = map.get(tableColumn.getTableName());
                columns.add(tableColumn);
            } else {
                List<TableColumn> columns = new ArrayList<>();
                columns.add(tableColumn);
                map.put(tableColumn.getTableName(), columns);
            }
        }

        return map;
    }

}
